# _*_ coding : utf-8 _*_
# @Time : 2022/8/11 10:23
# @Author : Moonquake
# @File : 20.解析_获取百度一下
# @Project : python
import urllib.request

url= 'https://www.baidu.com'

headers = {

    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0'
}

request = urllib.request.Request(url = url,headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode('utf-8')

from lxml import etree
# 解析服务器文件
tree = etree.HTML(content)
# xpath的返回值是一个列表类型的数据
result = tree.xpath('//input[@id="su"]/@value')
print(result)


